# 线程  多线程IO密集型
# 线程下的数据是共享的
import time
from threading import Thread


# 方式一
def task(name):
    print(f'{name} is running')
    time.sleep(2)
    print(f'{name} is over')


# if __name__ == '__main__':
#     t = Thread(target=task, args=('jack',))
#     t.start()
#     print('主线程运行')


# 方式二
class MyThread(Thread):
    def __init__(self, name):
        super().__init__()
        self.name = name

    def run(self):
        print(f'{self.name} is running')
        time.sleep(2)
        print(f'{self.name} is over')


if __name__ == '__main__':
    t = MyThread('tom')
    t.start()
    print('主线程运行')


